package com.coffee.admin.controller.supplier;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.coffee.admin.api.supplier.result.SupplierResult;
import com.coffee.admin.api.supplier.service.SupplierService;
import com.coffee.admin.controller.BaseController;
import com.coffee.core.anotation.OperLog;
import com.coffee.core.anotation.SupplierLoginCheck;
import com.coffee.core.anotation.SupplierLoginCheck;
import com.coffee.core.entity.Page;
import com.coffee.core.entity.PagerInfo;
import com.coffee.core.enums.ExceptionEnum;
import com.coffee.core.enums.SkuSalesInformationTypeEnum;
import com.coffee.core.enums.SkuTypeEnum;
import com.coffee.core.exception.BusinessException;
import com.coffee.core.result.Result;
import com.coffee.order.api.sku.req.HostRegionalSkuSalesInformationReq;
import com.coffee.order.api.sku.req.HostSkuSalesInformationReq;
import com.coffee.order.api.sku.result.PeriodizationSkuResult;
import com.coffee.order.api.sku.service.EnjoyBeforePaySkuService;
import com.coffee.order.api.sku.service.PeriodizationSkuService;
import com.coffee.sku.api.inquire.rep.InquireSkuListRep;
import com.coffee.sku.api.inquire.result.InquireSkuContentResult;
import com.coffee.sku.api.inquire.service.InquireSkuContentService;
import com.coffee.sku.api.sku.req.SkuUpdateReq;
import com.coffee.sku.api.sku.result.*;
import com.coffee.sku.api.sku.req.SkuAddReq;
import com.coffee.sku.api.sku.req.SkuListReq;
import com.coffee.sku.api.sku.service.RegionalSkuService;
import com.coffee.sku.api.sku.service.SkuContentService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/supplier/sku")
public class SupplierSkuController extends BaseController {

    @DubboReference(check = false)
    private SkuContentService skuContentService;
    @DubboReference(check = false)
    private InquireSkuContentService inquireSkuContentService;
    @DubboReference(check = false)
    private SupplierService supplierService;
    @DubboReference(check = false)
    private EnjoyBeforePaySkuService enjoyBeforePaySkuService;
    @DubboReference(check = false)
    private RegionalSkuService regionalSkuService;
    @DubboReference(check = false)
    private PeriodizationSkuService periodizationSkuService;

    @OperLog(operModul = "供应商-商品管理-商品管理", operDesc = "分页查询商品管理列表")
    @SupplierLoginCheck(alias = "SupplierSkuListAlias")
    @RequestMapping(value = "/findList", method = {RequestMethod.POST})
    public Result<Page<SkuListResult>> findList(HttpServletRequest request, @RequestBody SkuListReq params) {
        SupplierResult supplierResult = supplierService.getDetail(getSupplier().getSupplierId());
        if (!supplierResult.getSalePermission().contains(SkuTypeEnum.SKU.getCode())) {
            return Result.failed(ExceptionEnum.ERROR_200014);
        }
        Result<Page<SkuListResult>> result = Result.success(null);
        PagerInfo pagerInfo = setDefaultPageInfo(params.getPageSize(), params.getPageIndex());
        Integer status = params.getStatus();
        if (status != null && status == 0) {
            params.setIsApprove("W");
        } else if (status != null && status == 1) {
            params.setIsApprove("N");
        } else if (status != null && status == 2) {
            params.setIsApprove("Y");
        } else if (status != null && status == 3) {
            params.setIsEnable("N");
        } else if (status != null && status == 4) {
            params.setIsEnable("Y");
        }
        params.setSkuType(SkuTypeEnum.SKU.getCode());
        params.setSupplierId(getSupplier().getSupplierId());
        params.setIsDelete("N");
        params.setType(SkuSalesInformationTypeEnum.GENERAL.getCode());
        result.setData(skuContentService.findList(params, pagerInfo));
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-商品详情", operDesc = "商品详情")
    @SupplierLoginCheck(alias = "SupplierSkuOperationAlias")
    @RequestMapping(value = "/detail")
    public Result<SkuContentResult> detail(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        SupplierResult supplierResult = supplierService.getDetail(getSupplier().getSupplierId());
        if (!supplierResult.getSalePermission().contains(SkuTypeEnum.SKU.getCode())) {
            return Result.failed(ExceptionEnum.ERROR_200014);
        }
        Integer id = jsonObject.getInteger("skuId");
        Result<SkuContentResult> result = Result.success(null);
        SkuContentResult detail = null;
        try {
            detail = skuContentService.getDetail(id);
        } catch (BusinessException e) {
            e.printStackTrace();
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData(detail);
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-新增商品", operDesc = "新增商品")
    @SupplierLoginCheck(alias = "SupplierSkuOperationAlias")
    @RequestMapping(value = "/add", method = {RequestMethod.POST})
    public Result<String> add(HttpServletRequest request, @RequestBody SkuAddReq skuAddReq) {
        Result<String> result = Result.success(null);
        SupplierResult supplierResult = supplierService.getDetail(getSupplier().getSupplierId());
        if (!supplierResult.getSalePermission().contains(SkuTypeEnum.SKU.getCode())) {
            return Result.failed(ExceptionEnum.ERROR_200014);
        }
        try {
            skuAddReq.setSupplierId(getSupplier().getSupplierId());
            skuContentService.addSku(skuAddReq);
        } catch (BusinessException e) {
            e.printStackTrace();
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-修改商品", operDesc = "修改商品")
    @SupplierLoginCheck(alias = "SupplierSkuOperationAlias")
    @RequestMapping(value = "/update", method = {RequestMethod.POST})
    public Result<String> updateSku(HttpServletRequest request, @RequestBody SkuUpdateReq skuUpdateReq) {
        Result<String> result = Result.success(null);
        SupplierResult supplierResult = supplierService.getDetail(getSupplier().getSupplierId());
        if (!supplierResult.getSalePermission().contains(SkuTypeEnum.SKU.getCode())) {
            return Result.failed(ExceptionEnum.ERROR_200014);
        }
        try {
            skuUpdateReq.setSupplierId(getSupplier().getSupplierId());
            skuContentService.updateSku(skuUpdateReq);
        } catch (BusinessException e) {
            e.printStackTrace();
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-商品上下架", operDesc = "商品上下架")
    @SupplierLoginCheck(alias = "SupplierSkuOperationAlias")
    @RequestMapping(value = "/updateIsEnable", method = {RequestMethod.POST})
    public Result<String> updateIsEnable(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        SupplierResult supplierResult = supplierService.getDetail(getSupplier().getSupplierId());
        if (!supplierResult.getSalePermission().contains(SkuTypeEnum.SKU.getCode())) {
            return Result.failed(ExceptionEnum.ERROR_200014);
        }
        Integer id = jsonObject.getInteger("skuId");
        String isEnable = jsonObject.getString("isEnable");
        Result<String> result = Result.success(null);
        try {
            skuContentService.updateIsEnable(id, isEnable, SkuTypeEnum.SKU.getCode(), getSupplier().getSupplierId());
        } catch (BusinessException e) {
            e.printStackTrace();
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-商品删除", operDesc = "商品删除")
    @SupplierLoginCheck(alias = "SupplierSkuOperationAlias")
    @RequestMapping(value = "/delete", method = {RequestMethod.POST})
    public Result<String> delete(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        SupplierResult supplierResult = supplierService.getDetail(getSupplier().getSupplierId());
        if (!supplierResult.getSalePermission().contains(SkuTypeEnum.SKU.getCode())) {
            return Result.failed(ExceptionEnum.ERROR_200014);
        }
        Integer id = jsonObject.getInteger("skuId");
        Result<String> result = Result.success(null);
        skuContentService.delete(id);
        result.setData("SUCCESS");
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-添加先享后付商品", operDesc = "添加先享后付商品")
    @SupplierLoginCheck(alias = "SupplierEnjoySkuOperationAlias")
    @RequestMapping(value = "/enjoy/add", method = {RequestMethod.POST})
    public Result<String> enjoySku(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        JSONArray skuIdJSONArray = jsonObject.getJSONArray("skuIds");
        List<Integer> skuIds = JSONObject.parseArray(skuIdJSONArray.toJSONString(), Integer.class);
        Result<String> result = Result.success(null);
        try {
            enjoyBeforePaySkuService.addBySkuIds(skuIds);
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-删除先享后付商品", operDesc = "删除先享后付商品")
    @SupplierLoginCheck(alias = "SupplierEnjoySkuOperationAlias")
    @RequestMapping(value = "/enjoy/delete", method = {RequestMethod.POST})
    public Result<String> enjoySkuDelete(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Integer skuId = jsonObject.getInteger("skuId");
        Result<String> result = Result.success(null);
        enjoyBeforePaySkuService.deleteBySkuId(skuId);
        result.setData("SUCCESS");
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-商品管理", operDesc = "分页查询商品管理列表")
    @SupplierLoginCheck(alias = "SupplierEnjoySkuListAlias")
    @RequestMapping(value = "/enjoy/findList", method = {RequestMethod.POST})
    public Result<Page<SkuListResult>> enjoyFindList(HttpServletRequest request, @RequestBody SkuListReq params) {
        Result<Page<SkuListResult>> result = Result.success(null);
        PagerInfo pagerInfo = setDefaultPageInfo(params.getPageSize(), params.getPageIndex());
        params.setSkuType(SkuTypeEnum.SKU.getCode());
        params.setIsApprove("Y");
        params.setIsEnable("Y");
        params.setIsDelete("N");
        params.setSupplierId(getSupplier().getSupplierId());
        result.setData(enjoyBeforePaySkuService.getPager(params, pagerInfo));
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-添加区域商品", operDesc = "添加区域商品")
    @SupplierLoginCheck(alias = "SupplierRegionalSkuOperationAlias")
    @RequestMapping(value = "/regional/add", method = {RequestMethod.POST})
    public Result<String> regionalSku(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        JSONArray regionalSkuSalesInformationResultsJSONArray = jsonObject.getJSONArray("regionalSkuSalesInformationResults");
        Integer skuId = jsonObject.getInteger("skuId");
        String isMembersExclusive = jsonObject.getString("isMembersExclusive");
        List<RegionalSkuSalesInformationResult> regionalSkuSalesInformationResults = JSONObject.parseArray(regionalSkuSalesInformationResultsJSONArray.toJSONString(), RegionalSkuSalesInformationResult.class);
        Result<String> result = Result.success(null);
        try {
            regionalSkuService.addBySkuIds(skuId,isMembersExclusive,regionalSkuSalesInformationResults);
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-修改区域商品", operDesc = "修改区域商品")
    @SupplierLoginCheck(alias = "SupplierRegionalSkuOperationAlias")
    @RequestMapping(value = "/regional/update", method = {RequestMethod.POST})
    public Result<String> regionalSkuUpdate(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        JSONArray regionalSkuSalesInformationResultsJSONArray = jsonObject.getJSONArray("regionalSkuSalesInformationResults");
        Integer skuId = jsonObject.getInteger("skuId");
        String isMembersExclusive = jsonObject.getString("isMembersExclusive");
        List<RegionalSkuSalesInformationResult> regionalSkuSalesInformationResults = JSONObject.parseArray(regionalSkuSalesInformationResultsJSONArray.toJSONString(), RegionalSkuSalesInformationResult.class);
        Result<String> result = Result.success(null);
        try {
            regionalSkuService.updateBySkuIds(skuId,isMembersExclusive, regionalSkuSalesInformationResults);
        } catch (BusinessException e) {
            return Result.failed(e.getCode(), e.getMessage());
        }
        result.setData("SUCCESS");
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-删除区域商品", operDesc = "删除区域商品")
    @SupplierLoginCheck(alias = "SupplierRegionalSkuOperationAlias")
    @RequestMapping(value = "/regional/delete", method = {RequestMethod.POST})
    public Result<String> regionalDelete(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Integer skuId = jsonObject.getInteger("skuId");
        Result<String> result = Result.success(null);
        regionalSkuService.deleteBySkuId(skuId);
        result.setData("SUCCESS");
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-查询区域商品", operDesc = "分页查询查询区域商品")
    @SupplierLoginCheck(alias = "SupplierRegionalSkuListAlias")
    @RequestMapping(value = "/regional/findList", method = {RequestMethod.POST})
    public Result<Page<SkuListResult>> regionalFindList(HttpServletRequest request, @RequestBody SkuListReq params) {
        Result<Page<SkuListResult>> result = Result.success(null);
        PagerInfo pagerInfo = setDefaultPageInfo(params.getPageSize(), params.getPageIndex());
        params.setSkuType(SkuTypeEnum.SKU.getCode());
        params.setIsApprove("Y");
        params.setIsEnable("Y");
        params.setIsDelete("N");
        params.setSupplierId(getSupplier().getSupplierId());
        result.setData(regionalSkuService.getPager(params, pagerInfo));
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-区域商品详情", operDesc = "查询查询区域商品详情")
    @SupplierLoginCheck(alias = "SupplierRegionalSkuListAlias")
    @RequestMapping(value = "/regional/findDetail", method = {RequestMethod.POST})
    public Result<SkuListResult> regionalFindDetail(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Result<SkuListResult> result = Result.success(null);
        Integer skuId = jsonObject.getInteger("skuId");
        result.setData(regionalSkuService.getSkuListResult(skuId));
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-周期购商品列表", operDesc = "分页查询周期购商品列表")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuListAlias")
    @RequestMapping(value = "/periodization/findList", method = {RequestMethod.POST})
    public Result<Page<PeriodizationSkuListResult>> periodizationFindList(HttpServletRequest request, @RequestBody SkuListReq params) {
        Result<Page<PeriodizationSkuListResult>> result = Result.success(null);
        PagerInfo pagerInfo = setDefaultPageInfo(params.getPageSize(), params.getPageIndex());
        params.setSkuType(SkuTypeEnum.SKU.getCode());
        params.setSupplierId(getSupplier().getSupplierId());
        result.setData(periodizationSkuService.getPager(params, pagerInfo));
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-查询周期购商品详情", operDesc = "查询周期购商品详情")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuListAlias")
    @RequestMapping(value = "/periodization/getDetail", method = {RequestMethod.POST})
    public Result<PeriodizationSkuDetailResult> getDetail(HttpServletRequest request, @RequestBody SkuListReq params) {
        Result<PeriodizationSkuDetailResult> result = Result.success(null);
        result.setData(periodizationSkuService.getDetail(params.getSkuId()));
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-启用禁用周期购商品", operDesc = "启用禁用周期购商品")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/updateIsEnable", method = {RequestMethod.POST})
    public Result<Integer> periodizationUpdateIsEnable(HttpServletRequest request, @RequestBody SkuListReq params) {
        Result<Integer> result = Result.success(null);
        try {
            result.setData(periodizationSkuService.updateIsEnable(params.getSkuId(), params.getIsEnable()));
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-周期购商品添加", operDesc = "周期购商品添加")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/add", method = {RequestMethod.POST})
    public Result<Integer> add(HttpServletRequest request, @RequestBody PeriodizationSkuResult req) {
        Result<Integer> result = Result.success(null);
        try {
            result.setData(periodizationSkuService.add(req));
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-周期购商品修改", operDesc = "周期购商品修改")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/update", method = {RequestMethod.POST})
    public Result<Integer> update(HttpServletRequest request, @RequestBody PeriodizationSkuResult req) {
        Result<Integer> result = Result.success(null);
        try {
            result.setData(periodizationSkuService.update(req));
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-周期购商品添加副商品", operDesc = "周期购商品添加副商品")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/addBySkuIds", method = {RequestMethod.POST})
    public Result<Integer> addBySkuIds(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Integer hostSkuId = jsonObject.getInteger("hostSkuId");
        JSONArray skuIdJSONArray = jsonObject.getJSONArray("skuIds");
        List<Integer> skuIds = JSONObject.parseArray(skuIdJSONArray.toJSONString(), Integer.class);
        Result<Integer> result = Result.success(null);
        try {
            periodizationSkuService.addBySkuIds(hostSkuId, skuIds);
            result.setData(null);
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-周期购商品添加规格", operDesc = "周期购商品添加规格")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/addHostRegionalSkuInformation", method = {RequestMethod.POST})
    public Result<Integer> addHostRegionalSkuSalesInformationReq(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Integer hostSkuId = jsonObject.getInteger("skuId");
        JSONArray skuIdJSONArray = jsonObject.getJSONArray("hostSkuSalesInformationReq");
        List<HostRegionalSkuSalesInformationReq> hostRegionalSkuSalesInformationReqs = JSONObject.parseArray(skuIdJSONArray.toJSONString(), HostRegionalSkuSalesInformationReq.class);
        Result<Integer> result = Result.success(null);
        try {
            periodizationSkuService.addHostRegionalSkuSalesInformationReq(hostSkuId, hostRegionalSkuSalesInformationReqs);
            result.setData(null);
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-周期购商品修改规格", operDesc = "周期购商品修改规格")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/updateHostRegionalSkuInformation", method = {RequestMethod.POST})
    public Result<Integer> updateHostRegionalSkuSalesInformationReq(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Integer skuId = jsonObject.getInteger("skuId");
        Integer hostSkuId = jsonObject.getInteger("hostIdSkuId");
        JSONArray skuIdJSONArray = jsonObject.getJSONArray("hostSkuSalesInformationReq");
        List<HostRegionalSkuSalesInformationReq> hostRegionalSkuSalesInformationReqs = JSONObject.parseArray(skuIdJSONArray.toJSONString(), HostRegionalSkuSalesInformationReq.class);
        Result<Integer> result = Result.success(null);
        try {
            periodizationSkuService.updateHostRegionalSkuSalesInformationReq(hostSkuId, skuId, hostRegionalSkuSalesInformationReqs);
            result.setData(null);
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-周期购商品设置价格", operDesc = "周期购商品设置价格")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/addHostSkuSalesInformation", method = {RequestMethod.POST})
    public Result<Integer> addHostSkuSalesInformation(HttpServletRequest request, @RequestBody HostSkuSalesInformationReq req) {
        Result<Integer> result = Result.success(null);
        try {
            Integer integer = periodizationSkuService.addHostSkuSalesInformation(req);
            result.setData(integer);
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-周期购商品修改价格", operDesc = "周期购商品修改价格")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/deleteHostSkuSalesInformation", method = {RequestMethod.POST})
    public Result<Integer> deleteHostSkuSalesInformation(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Integer id = jsonObject.getInteger("id");
        Integer hostId = jsonObject.getInteger("hostId");
        Result<Integer> result = Result.success(null);
        try {
            periodizationSkuService.deleteHostSkuSalesInformation(id, hostId);
            result.setData(null);
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }


    @OperLog(operModul = "供应商-商品管理-周期购商品修改价格", operDesc = "周期购商品修改价格")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/deleteViceSku", method = {RequestMethod.POST})
    public Result<Integer> deleteViceSku(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Integer hostSkuId = jsonObject.getInteger("hostSkuId");
        Integer skuId = jsonObject.getInteger("skuId");
        Result<Integer> result = Result.success(null);
        try {
            periodizationSkuService.deleteViceSku(hostSkuId, skuId);
            result.setData(null);
        } catch (BusinessException e) {
            result.setCode(e.getCode());
            result.setMsg(e.getMessage());
        }
        return result;
    }

    @OperLog(operModul = "供应商-商品管理-周期购商品修改价格", operDesc = "周期购商品修改价格")
    @SupplierLoginCheck(alias = "SupplierPeriodizationSkuOperateAlias")
    @RequestMapping(value = "/periodization/deleteBySkuId", method = {RequestMethod.POST})
    public Result<Integer> deleteBySkuId(HttpServletRequest request, @RequestBody JSONObject jsonObject) {
        Integer id = jsonObject.getInteger("skuId");
        Result<Integer> result = Result.success(null);
        periodizationSkuService.deleteBySkuId(id);
        result.setData(null);
        return result;
    }
}
